import $ from '../common';
Page({
  data: {
    page:1,
    tip:'上滑加载更多',
    list:[]
  },
  onLoad(e) {
    this.setData({
      student_uuid:e.student_uuid,
      group_uuid:e.group_uuid
    })
    this.getinfo()
  },
  onShow() {

  },
  onReachBottom() {
    this.getinfo(0)
  },
  getinfo(){
    const{student_uuid,list,group_uuid}=this.data
    $.get('/group/orders',{
      page:this.data.page,
      limit:20,
      group_uuid:group_uuid,
      student_uuid:student_uuid
    },res=>{
      this.data.page++
      if(res.orders.length<20){
        this.data.tip='已经到底了'
      }else{
        this.data.tip='上滑加载更多'
      }
      this.setData({
        list:[...list,...res.orders],
        page:this.data.page,
        tip:this.data.tip
      })
    })
  },
  godetailorpay(e){
    const{idx,order_uuid='',item='',uuid=''}=e.currentTarget.dataset
    let id=this.data.active!=2?uuid:order_uuid
    if(idx==1){
      $.navigateTo(`/index/orderdetail?order_uuid=${id}`)
    }else{
      $.navigateTo(`/index/checkstand?order_uuid=${order_uuid}&info=${JSON.stringify(item)}`)
    }
  }
})